<template>
  <div class="login-container">
    <NuxtLink to="/">
      <span class="icon-close iconfont close" />
    </NuxtLink>
    <div class="header flex flex-column justify-center align-center">
      <span class="logo" />
      <div class="f-16">
        登录博MOCK
      </div>
      <div class="f-14">
        分享生活 发现世界
      </div>
    </div>
    <van-form @submit="onSubmit">
      <div class="flex align-center">
        <NuxtLink to="/login/phoneArea">
          <span
            class="flex align-center f-14"
          ><span>+{{ $store.state.login.phoneAreaTop }}</span> <van-icon
            name="arrow-down"
          /></span>
        </NuxtLink>
        <van-field
          v-model="phone"
          :error="false"
          clearable
          name="phone"
          label=""
          placeholder="输入手机号"
          :rules="[
            { required: true, message: '请输入手机号' },
            {
              required: true,
              validator: phoneValidator,
              message: '请输入正确的手机号',
            },
          ]"
        />
      </div>

      <van-button
        size="small"
        :style="{ opacity: phone ? 1 : 0.5 }"
        class="get-vcode"
        round
        block
        ative-type="submit"
      >
        获取验证码
      </van-button>
    </van-form>
    <NuxtLink :to="{path:'/login/accountPasswordLogin',query:{url:$route.query.url}}">
      <van-button
        size="small"
        class="account-login"
        round
        block
      >
        用账号密码登录
      </van-button>
    </NuxtLink>
    <div class="flex mt-20 justify-between">
      <NuxtLink to="/login/accountLogin">
        <span class="f-14 color-blue">手机号已更换</span>
      </NuxtLink>
      <NuxtLink to="/register">
        <span class="f-14 color-blue">注册</span>
      </NuxtLink>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      phone: ''
    }
  },
  methods: {
    // 手机号校验
    phoneValidator (value, rule) {
      const reg_tel = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/
      return reg_tel.test(value)
    },
    async onSubmit (values) {

    }
  }
}
</script>

<style lang="scss" scoped>
.login-container {
  padding: 10px;
  .close {
    font-size: 25px;
  }
  .header {
    margin-bottom: 50px;
    .logo {
      margin-bottom: 10px;
      width: 50px;
      height: 50px;
      background: url("@/assets/imgs/logo.jpg");
      background-size: 100% 100%;
    }
  }
  .get-vcode {
    margin-top: 20px;
    color: #fff;
    font-size: 14px;
    background: linear-gradient(#fccf31, #f55555);
  }
  .account-login{
    font-size: 14px;
    margin-top: 20px;
    color: #f55555;
    border-color: #f55555;
    background: #fff;
  }
  .color-blue{
    color:#4169E1
  }
}
</style>
